package ua.edu.sumdu.j2se.roman.lab1.util;

/**
 * Creates for logging a message at a particular log level like INFO, DEBUG, ERROR. Depending on requirements possible tune the level of logging.
 */
public class Log {
    public static final int INFO = 0;
    public static final int DEBUG = 2;
    public static final int ERROR = 4;
    /**
     * Contain level of logging.
     */
    private static int logLevel = ERROR;

    /**
     * Writes a different message depending on the log level.
     *
     * @param level
     * @param message
     */
    public static void log(int level, String message) {
        if (level >= logLevel) {
            System.out.println("#### " + message + " ####");
        }
    }

    /**
     * Writes debug message.
     *
     * @param message
     */
    public static void d(String message) {
        log(DEBUG, message);
    }

    /**
     * Writes error message.
     *
     * @param message
     */
    public static void e(String message) {
        log(ERROR, message);
    }

    /**
     * Writes error message with throwable description.
     *
     * @param message
     * @param throwable
     */
    public static void e(String message, Throwable throwable) {
        log(ERROR, message);
        if (ERROR >= logLevel) {
            System.out.println(throwable);
        }
    }

    /**
     * Writes inform message.
     *
     * @param message
     */
    public static void i(String message) {
        log(INFO, message);
    }
}
